//
//  ViewController.m
//  SQLite
//
//  Created by 金色榜样研发组 on 2019/5/28.
//  Copyright © 2019 Golden Bangyang (beijing) Cul Ture Media Investment Co. All rights reserved.
//

#import "ViewController.h"
#import "TestModel/TestModel.h"

#import "SqliteTool/SqliteTool.h"
//#import "GetDataBase.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSString *modelListPath = [[NSBundle mainBundle] pathForResource:@"ModelList.plist" ofType:@""];
    NSArray *personDicArr = [NSArray arrayWithContentsOfFile:modelListPath];
    NSLog(@"personDicArr = %@",personDicArr);
    NSArray *personModelArr = [TestModel mj_objectArrayWithKeyValuesArray:personDicArr];
    [[SqliteTool shareinstance] createSqliteDB];
    NSLog(@"开始     插入模型数据");
    [[SqliteTool shareinstance] insertModel:personModelArr];
    NSLog(@"结束     插入模型数据");
    NSLog(@"开始     插入模型字典");
    [[SqliteTool shareinstance] insertModel:personDicArr];
    NSLog(@"结束     插入模型字典");
    
    NSArray *modelArr = [[SqliteTool shareinstance] selectAllModel:[TestModel class]];
    NSLog(@"modelArr = %@",modelArr);
    
//    for (NSInteger i = 0; i < modelArr.count; ++i) {
//        TestModel *model = modelArr[i];
//        NSLog(@"model = %@",model);
//    }
    //删除数据库中的表格
    [[SqliteTool shareinstance] deleteSQLiteTable:[TestModel class]];
    
    [[SqliteTool shareinstance] closeSqliteDB];
    
//    [[GetDataBase shareDataBase] wzCreateTableID:@"MyTestTable"];
//    [[GetDataBase shareDataBase] insertRecorderDataWithTableName:@"MyTestTable" andModelArray:personModelArr];
//
//    NSArray *dataArr = [NSArray arrayWithArray:[[GetDataBase shareDataBase] wzGainTableRecoderID:@"MyTestTable"]];
//    NSLog(@"dataArr = %@",dataArr);

}

@end
